package com.gs.seckill.service.impl;

import com.gs.common.core.redis.RedisCache;
import com.gs.gaosheng.domain.GsGoods;
import com.gs.gaosheng.domain.GsSecKill;
import com.gs.seckill.mapper.SecKillMapper;
import com.gs.seckill.service.SecKillService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class SecKillServiceImpl implements SecKillService {

  @Resource
  private SecKillMapper secKillMapper;

  @Resource
  private RedisCache redisCache;

  @Override
  public Boolean flashSale(Long secKillUserId, Long secKillGoodsId) {
    List<GsSecKill> isBuy = secKillMapper.flashSale(secKillUserId, secKillGoodsId);
//    List<GsGoods> gsGoods = redisCache.getCacheList("seckill");//取出缓存中所有秒杀商品的全部信息
    return !(isBuy.size() == 0);
  }

  @Override
  public List<GsGoods> findByStoreDesc() {
    return secKillMapper.findByStoreDesc();
  }
}
//      for (GsGoods goods : gsGoods) { //遍历出
//        if (goods.getGoodsId() == secKillGoodsId) {
//          if (goods.getGoodsStore() == 0){
//            return false;
//          }
//        }
//      }

